<template>
    <view>
		
		<view class="cu-list menu sm-border card-menu margin-top guoshao-menu" >
			<view class="cu-item guoshao-menu">
				<view class="">
					<view class="guoshao-touxiang-one ">
						<view class="cuIcon-vip cu-tag badge guoshao-vip" v-if="talentInfo && talentInfo.vipAccount == 1"></view>
						<image :src="user.pic" class=""></image>
					</view>
					<view class="guoshao-user-name">
						<text class="text-black" >推广口令：{{talentInfo && talentInfo.word}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="cu-list menu sm-border card-menu margin-top " >
		
			<view class="cu-item arrow "  @click="jumpClick" 
			data-link="/pages_user/notice/notice" data-tp="notice">
				<view class="content">
					<text class="cuIcon-notice text-blue"></text>
					<text class="text-black">消息通知</text>
				</view>
				<view class=" cuIcon-title text-red " v-if="noticeCount > 0">
					<!-- <view class="cu-tag round bg-red ">1</view> -->
				</view>
			</view>
			
			<view class="cu-item arrow" @click="jumpClick" data-link="/pages_user/wallet/wallet">
			    <view class="content">
			        <text class="cuIcon-moneybag text-blue"></text>
			        <text class="text-black">钱包·提现</text>
			    </view>
			    <view class="action">
			        <text class="text-grey text-sm"></text>
			    </view>
			</view>
			<view class="cu-item arrow "  @click="jumpClick"
			data-link="/pages_user/userinfo/userinfo" data-tp="notice">
				<view class="content">
					<text class="cuIcon-friendfamous text-blue"></text>
					<text class="text-black">个人资料</text>
				</view>
			</view>
		
		</view>
		
		<view class="cu-list menu sm-border card-menu margin-top " >
			<view class="cu-item arrow" @click="jumpClick"
			data-link="/pages_user/film/film" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-list text-blue"></text>
			        <text class="text-black">短剧管理</text>
			    </view>
			</view>
			
			<view class="cu-item arrow" @click="jumpClick"
			data-link="/pages_user/film/resources/list" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-list text-blue"></text>
			        <text class="text-black">资源管理</text>
			    </view>
			</view>
			
			<view class="cu-item arrow" @click="jumpClick"
			data-link="/pages_user/film/resources/form" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-upload text-blue"></text>
			        <text class="text-black">上传资源</text>
			    </view>
			</view>
			
			<!-- <view class="cu-item arrow" @click="jumpClick"
			data-link="/pages_user/wallpaper/wallpaper" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-list text-blue"></text>
			        <text class="text-black">素材管理</text>
			    </view>
			</view>
			
			<view class="cu-item arrow" @click="jumpClick" 
			data-link="/pages/upload/upload" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-upload text-blue"></text>
			        <text class="text-black">上传素材</text>
			    </view>
			</view> -->
			<!--
			<view class="cu-item arrow" @click="jumpClick" 
			data-link="/pages/webview/webview" data-modul="2">
			    <view class="content">
			        <text class="cuIcon-upload text-blue"></text>
			        <text class="text-black">H5上传</text>
			    </view>
			</view>		
			-->
		
		</view>
		
		<view class="cu-list menu sm-border card-menu margin-top" >
		
			<!-- <view class="cu-item arrow" >
				<view class="content" @click="jumpClick"
				data-link="/pages/talent/cooperation/cooperation">
					<text class="cuIcon-mark text-blue"></text>
					<text class="text-black">联系我们</text>
				</view>
			</view> -->
			<view class="cu-item arrow" @click="jumpClick"
			data-link="/pages/invitation/record">
			    <view class="content">
			        <text class="cuIcon-friend text-blue"></text>
			        <text class="text-black">邀请记录</text>
			    </view>
			</view>
			
			<!--#ifdef MP -->
			<view class="cu-item arrow" >
				<button class="cu-btn content" open-type="share">
					<text class="cuIcon-share text-blue"></text>
					<text class="text-black">邀请好友</text>
				</button>
			</view>
			<!--#endif-->
			
			<!--#ifndef MP -->
			<view class="cu-item arrow" @click="inviteClick">
			    <view class="content">
			        <text class="cuIcon-friend text-blue"></text>
			        <text class="text-black">邀请好友</text>
			    </view>
			</view>
			<!--#endif-->
			
			<!-- <view class="cu-item arrow" @click="jumpClick" data-link="/pages/qrcode/qrcode">
				<view class="content">
					<text class="cuIcon-qrcode text-blue"></text>
					<text class="text-black">二维码邀请</text>
				</view>
			</view> -->
			
			<view class="cu-item arrow" @click="jumpClick" data-link="/pages/setup/setup">
				<view class="content">
					<text class="cuIcon-settings text-blue"></text>
					<text class="text-black">设置</text>
				</view>
			</view>
		
			<view class="cu-item arrow" v-if="admin" @click="jumpClick" 
			data-link="/pages/talent/approve/approve">
				<view class="content">
					<text class="cuIcon-edit text-blue"></text>
					<text class="text-black">创作者审核</text>
				</view>
			</view>
			
		</view>

        <!--加载框 start-->
        <tui-loading :visible="loading"></tui-loading>
        <!--加载框 end-->
    </view>
</template>

<script>
import tuiLoading from '../../components/loading/loading';
/*
 * Author: 郭少
 * github: https://github.com/guoshao99/wallpaper-applet
 * gitee: https://gitee.com/guoshao99/wallpaper-applet
 * QQ：2549789059
 * 微信：2549789059
 */

const Authentication = require('../../utils/authentication.js');

const util = require('../../utils/util.js');

const http = require('../../utils/http.js');

const Constants = require('../../utils/constants.js');

let setinad;

export default {
    components: {
        tuiLoading
    },
    data() {
        return {
			user:Authentication.getUser(),
            //是否显示modal
            modelShow: false,
            //modal的高度
            integra: 0,

            loading: false,
			loginReq:false,
			userId:Authentication.getUserId(),
			admin:false,
			noticeCount:0,
			talentInfo:null,
			configs:[]
        };
    },
    onLoad() {
        let that = this; //配置信息  begin
		this.getDateSub3();
		//获取达人信息
		this.getTalentInfo();
		
		util.getConfigs(this,"admins",() => {
			if(that.configs.length > 0){
				let userIds = that.configs[0].value.split(",");
				
				that.configs = [];
				for (var i = 0; i < userIds.length; i++) {
					that.configs.push(userIds[i]);
				}
			}
			that.admin = that.configs.includes(Authentication.getUser().userId)
		});
		
		//管理员用户ID
		// setTimeout(function(){
		// 	if(that.configs.length > 0){
		// 		let userIds = that.configs[0].value.split(",");
				
		// 		that.configs = [];
		// 		for (var i = 0; i < userIds.length; i++) {
		// 			that.configs.push(userIds[i]);
		// 		}
		// 	}
		// 	that.admin = that.configs.includes(Authentication.getUser().userId)
		// },100)
    },
    onShow: function (options) {
        let that = this;
        util.getshare(that);
        
        that.setData({
            user: Authentication.getUser(),
			userId:Authentication.getUserId()
        });
    },
    onHide() {
    },

	onShareAppMessage(res) {
		let that = this;
		return {
			title: '星光壁纸诚邀创作者入住',
			path: '/pages/apply/apply?recommenderWord='+that.talentInfo.word,
			imageUrl:'../../static/images/yaoqing.jpg'
		}
	},
	onShareTimeline: function () {
		let that = this;
	    return {
	        title: '星光壁纸诚邀创作者入住',
			path: '/pages/apply/apply?recommenderWord='+that.talentInfo.word,
			imageUrl:'../../static/images/yaoqing.jpg'
	    }
	},
    methods: {
        jumpClick: function (e) {
			
			let that= this;
			
            let tp = e.currentTarget.dataset.tp;
			let link = e.currentTarget.dataset.link;
			
			uni.navigateTo({
				url: link,
				 fail (error) {
				    }
			});
        },
		getDateSub3: function () {
		    let that = this;
		    var params = {
		        url: '/notice/getDateSub3',
		        method: 'GET',
		        data: {},
		        callBack: function (res) {
		            that.setData({
		                noticeCount: res.data
		            });
		        }
		    };
		    http.request(params);
		},
		getTalentInfo: function () {
		    let that = this;
		    var params = {
		        url: '/u/my/getTalentInfo',
		        method: 'POST',
		        data: {},
		        callBack: function (res) {
		            that.setData({
		                talentInfo: res.data
		            });
		        }
		    };
		    http.request(params);
		},
		/**
		 * 仅支持路由 /#/
		 */
		inviteClick(){
			let invUrl = 'pages/apply/apply?recommenderWord='+this.talentInfo.word
			
			let url = window.location.href; // 获取当前网页的完整URL
			let port = window.location.port; // 获取当前网页的端口号
			let protocol = url.split(':')[0]; // 提取协议部分（例如，http或https）
			let domain = url.split('/')[2]; // 提取域名部分（例如，www.example.com）
			//console.log(`Protocol: ${protocol}, Domain: ${domain}`); // 输出协议和域名
			//console.log(protocol + "://" + domain + "/#/"+ invUrl)
			let uri = protocol + "://" + domain + "/#/"+ invUrl
			uni.setClipboardData({
			    data: uri,
			    success: function (res) {
					uni.hideToast()
			      uni.showToast({
			      	title:'复制成功',
					icon: 'none'
			      })
			    }
			});
		}


    }
};
</script>

<style>
@import './ucenter.css';
</style>
